from core.support import set_cutscene
from core.item import Item
from core.action import Action

class Wine(Item):
    def __init__(self):
        Item.__init__(self, "wine")    # do basic initialization for every item
        self.has_wine = True
        
        # build list of actions
        self.add_action(drinkwine)
    
    def get_description(self):
        return "wine"
    
    def get_image(self):
        return "wine.jpg"


# define actions for this item
class drinkwine(Action):
    def __init__(self):
        Action.__init__(self, "drink_wine")    # do basic initialization for every action
        self.isItemAction="item"
    
    # return description of action (used in label on webpage)
    def get_description(self):
        return "Drink wine"
    
    # return http method to use when user clicks on this action
    # use "get" if just moving to another room.  if changing something
    # like the state of an inventory item or room then use "post"
    def get_method(self):
        return "post"
    
    # only works in basement. add cutscene
    def do_action(self,game,room,request):
        if self.item.has_wine:
            if room.get_id() == 'networkingHall':
                room.wine_drunk = True
                self.item.has_wine = False
                set_cutscene("You drink the wine and feel much more talkative.")
                room.drink_wine()
            else:
                room.wine_drunk = True
                self.item.has_wine = False
                set_cutscene("This is the incorrect place to drink the wine.")
        else:
            set_cutscene("You tip the bottle, but it is empty.")        
        return
    
    def is_enabled(self):
        if self.item.has_wine:
            return True
        else:
            return False